package com.ruitu.mall_98_2.mvp.model;

import com.ruitu.mall_98_2.dao.APIRetrofit;
import com.ruitu.mall_98_2.mvp.contract.CartContract;
import com.ruitu.router_module.bean.api.BaseResult;
import com.ruitu.router_module.bean.cart.CartBean;

import java.util.List;

import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class CartModel implements CartContract.Model {
    @Override
    public Observable<BaseResult<CartBean>> getCarts(String accountId) {
        return APIRetrofit.getDefault().getCarts(accountId)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }

    @Override
    public Observable<BaseResult> deleteByIds(String ids) {
        return APIRetrofit.getDefault().deleteByIds(ids)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    @Override
    public Observable<BaseResult> updateCartNum(String id, int num) {
        return APIRetrofit.getDefault().updateCartNum(id, num)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    @Override
    public Observable<BaseResult<String>> calCarts(String ids) {
        return APIRetrofit.getDefault().calCarts(ids)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }
}
